package com.wc.fortnight_blue_bridge.Q231019.清洁客房;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/20 0:05
 * @description https://www.lanqiao.cn/problems/19929/learning/?contest_id=212
 */
public class Main {
    /**
     * 典型的dp<p>
     * 先选三种, 从 1 ~ 9 选C(9, 1), 从剩下九个选 2 个 C(9, 2), C(9, 1) * C(9, 2)<p>
     * f[i][j] 表示第1 ~ i 个选完后有j个数出现了的方案数, f[1][1] = 1<p>
     * f[i][1] = f[i - 1][1]<p>
     * f[i][2] = (f[i - 1][2] * 2 + f[i - 1][1] * 2), 表示前面选了两个,那可以选这俩, 前面选了一个,可以选剩下的俩<p>
     * f[i][3] = (f[i - 1][3] * 3 + f[i - 1][2] * 1), 表示前面选了三个, 那就可以选这三, 前面选了两个, 只能选最后一个了<p>
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010, P = (int) 1e9 + 7;
    static long[][] f = new long[N][4];
    static int n;

    public static void main(String[] args) {
        f[1][1] = 1;
        for (int i = 2; i < N; i++) {
            f[i][1] = f[i - 1][1];
            f[i][2] = (f[i - 1][2] * 2 + f[i - 1][1] * 2) % P;
            f[i][3] = (f[i - 1][3] * 3 + f[i - 1][2]) % P;
        }
        int T = sc.nextInt();
        int base = 9 * 9 * 8 / 2;
        while (T-- > 0) {
            n = sc.nextInt();
            out.println(base * f[n][3] % P);
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
